#include "RenzoMath.h"
/*
inline Float4& rzNormalize(const Float4& v) {
	return Float4(v).normalize();
}

inline float rzDot(const Float4& f1, const Float4& f2) {
	return f1.dot(f2);
}

Math::Math()
{
}

Math::~Math()
{
}

int Math::Power(int x, int y) {
	int p = 1;
	for (int i = 0; i < y; i++)
		p *= x;
	
	return p;
}

float Math::Power(float x, int y) {
	float p = 1;
	for (int i = 0; i < y; i++)
		p *= x;
	
	return p;
}

void Math::Swap(int& a, int& b) {
	int c = a;
	a = b;
	b = c;
}



void Math::MatrixIdentity(float matrix[16]) {
	memset(matrix, 0, 16*sizeof(float));
	matrix[0] = 1;
	matrix[5] = 1;
	matrix[10] = 1;
	matrix[15] = 1;
}

// column major matrix - translate a relative distance 
void Math::Translate(Vector3f trans, float matrix[]) {
	matrix[0] = 1; matrix[4] = 0; matrix[8] = 0;  matrix[12] = trans.x;
	matrix[1] = 0; matrix[5] = 1; matrix[9] = 0;  matrix[13] = trans.y;
	matrix[2] = 0; matrix[6] = 0; matrix[10] = 1; matrix[14] = trans.z;
	matrix[3] = 0; matrix[7] = 0; matrix[11] = 0; matrix[15] = 1;
}

// column major matrix - rotate around Y axis 
void Math::RotateY(float angle, float matrix[16]) {
	float c = cos(angle);
	float s = sin(angle);
	matrix[0] = c; matrix[4] = 0; matrix[8]  = s; matrix[12] = 0;
	matrix[1] = 0; matrix[5] = 1; matrix[9]  = 0;  matrix[13] = 0;
	matrix[2] = -s; matrix[6] = 0; matrix[10] = c;  matrix[14] = 0;
	matrix[3] = 0; matrix[7] = 0; matrix[11] = 0;  matrix[15] = 1;
	 
}

// column major matrix - rotate around X axis 
void Math::RotateX(float angle, float matrix[16]) {
	float c = cos(angle);
	float s = sin(angle);
	matrix[0] = 1; matrix[4] = 0; matrix[8] = 0;  matrix[12] = 0;
	matrix[1] = 0; matrix[5] = c; matrix[9] = -s; matrix[13] = 0;
	matrix[2] = 0; matrix[6] = s; matrix[10] = c; matrix[14] = 0;
	matrix[3] = 0; matrix[7] = 0; matrix[11] = 0; matrix[15] = 1;
}

// column major matrix - rotate around Z axis 
void Math::RotateZ(float angle, float matrix[16]) {
	float c = cos(angle);
	float s = sin(angle);
	matrix[0] = c; matrix[4] = -s; matrix[8] = 0;  matrix[12] = 0;
	matrix[1] = s; matrix[5] = c;  matrix[9] = 0;  matrix[13] = 0;
	matrix[2] = 0; matrix[6] = 0;  matrix[10] = 1; matrix[14] = 0;
	matrix[3] = 0; matrix[7] = 0;  matrix[11] = 0; matrix[15] = 1;
}

void Math::Transpose(float a[16], float b[16]) {
	float t[16];
	int i, j;
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			t[i*4+j] = a[j*4+i];
		}
	}
	memcpy(b, t, sizeof(float)*16);
}


float Math::dot(const Float3 &a, const Float3 &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z;
}

float Math::dot(const Float4 &a, const Float4 &b) {
	return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
}

Float4 Math::power(const Float4& f, float e) {
	return Float4(pow(f.x, e), pow(f.y, e), pow(f.z, e), pow(f.w, e));
}
Float4 Math::power(const Float4& f, const Float4& e) {
	return Float4(pow(f.x, e.x), pow(f.y, e.y), pow(f.z, e.z), pow(f.w, e.w));
}
*/
